package com.jacobson.core.widget.security

import com.jacobson.core.widget.security.authc.AuthenticationToken
import com.jacobson.core.widget.security.exception.AuthenticationException
import io.reactivex.Observable

/**
 * ================================================
 *
 *  @author Wucz on 2018/7/19 18:02
 * ================================================
 */

/**
 * 登录对象
 * @author wucz on 2017-11-10.
 */

interface Subject {
    /**
     * 获取当前登录对象的信息
     * @return 登录信息
     */
    var principal: Any?

    /**
     * 是否是记住我
     * @return 是否是记住我 功能登录
     */
    var remembered: Boolean

    /**
     * 是否已授权
     * @return 是否已授权
     */
    var authenticated: Boolean

    /**
     * 登录
     * @param token 登录的Token
     * @throws AuthenticationException 登录异常
     */
    @Throws(AuthenticationException::class)
    fun login(token: AuthenticationToken): Observable<Subject?>

    /**
     * 退出登录
     */
    fun logout()
}
